﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using Microsoft.Phone.Data.Linq;
using Microsoft.Phone.Data.Linq.Mapping;
using System.ComponentModel;

namespace restaurant
{
    public class dbContextRestaurant : DataContext
    {
        // Specify the connection string as a static, used in main page and app.xaml.
        public static string DBConnectionString = "Data Source=isostore:/restaurant.sdf";
        public dbContextRestaurant(string constring) : base(constring) { }
        public Table<tblSeating> tblSeatings;
        public Table<tblEmpJob> tblEmpjobs;
        public Table<tblEMPLOYEE> tblEmployees;
        public Table<tblCustbill> tblCustbills;
        public Table<tblMENUITEMS> tblMenuitems;
        public Table<tblItemsOrdered> tblItemsordered;
        public Table<Person> person;
        public Table<Doctor> doctor;
        public Table<Devices> devices;
        public Table<GlucoseHist> GlucoseHist;
        public Table<GlucoseGoal> GlucoseGoal;
        public Table<Food> food;
        public Table<FoodHist> foodhistory;


    }
    [Table]
    public class tblMENUITEMS
    {
        public tblMENUITEMS() { }
        public tblMENUITEMS(int MINum, string MIDesc, float MIPrice, string MIType)
        {
            menunumber = MINum;
            desc = MIDesc;
            menuprice = MIPrice;
            menutype = MIType;
        }
        int _menunumber;
        string _desc;
        float _menuprice;
        string _menutype;
         [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
        public int menunumber
        {
            get { return _menunumber; }
            set { _menunumber = value; }
        }
        [Column]
        public string desc
        {
            get { return _desc; }
            set { _desc = value; }
        }
        [Column]
        public float menuprice
        {
            get { return _menuprice; }
            set { _menuprice = value; }
        }
        [Column]
        public string menutype
        {
            get { return _menutype; }
            set { _menutype = value; }
        }

    }
    [Table]
    public class tblEMPLOYEE
    {
        int _empid;
        string _name;
        DateTime _hiredate;
        float _hourpay;
        [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
        public int empid
        {
            get { return _empid; }
            set { _empid = value; }
        }
        [Column]
        public string name
        {
            get { return _name; }
            set { _name = value; }
        }
        [Column]
        public DateTime hiredate
        {
            get { return _hiredate; }
            set { _hiredate = value; }
        }
        [Column]
        public float hourpay
        {
            get { return _hourpay; }
            set { _hourpay = value; }
        }
        [Column]
        public int jobid;
        private EntityRef<tblEmpJob> _eJobID;
        [Association(Storage = "_eJobID", ThisKey = "jobid", IsForeignKey = true)]
        public tblEmpJob empJob
        {
            get { return this._eJobID.Entity; }
            set { this._eJobID.Entity = value; }
        }
    }
    [Table]
    public class tblCustbill
    {
        public tblCustbill() { }
        public tblCustbill(int BillNum, string TableID, string EmpID, DateTime BillStartTime, DateTime BillEndTime)
        {
            Bill = BillNum;           
            StartTime = BillStartTime;
            EndTime = BillEndTime;
        }
        int _Bill;
         [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
        public int Bill
        {
            get { return _Bill; }
            set { _Bill = value; }
        }

        [Column]
        public int empid;
        private EntityRef<tblEMPLOYEE> _empid;
        [Association(Storage = "_empid", ThisKey = "empid", IsForeignKey = true)]
        public tblEMPLOYEE employee
        {
            get { return this._empid.Entity; }
            set { this._empid.Entity = value; }
        }
      
        [Column]
        public int tableid;
        private EntityRef<tblSeating> _tableid;
        [Association(Storage = "_tableid", ThisKey = "tableid", IsForeignKey = true)]
        public tblSeating Seating
        {
            get { return this._tableid.Entity; }
            set { this._tableid.Entity = value; }
        }
       
        DateTime _StartTime;
        [Column]
        public DateTime StartTime
        {
            get { return _StartTime; }
            set { _StartTime = value; }
        }
        DateTime _EndTime;
        [Column]
        public DateTime EndTime
        {
            get { return _EndTime; }
            set { _EndTime = value; }
        }

    }
    [Table]
    public class tblItemsOrdered
    {
        public tblItemsOrdered() { }
        public tblItemsOrdered(int BillNum, string MINum, int QtyOrdered)
        {
            Qty = QtyOrdered;
        }

        [Column(IsPrimaryKey = true, DbType = "INT NOT NULL", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
        public int billnum;
        private EntityRef<tblCustbill> _billnum;
        [Association(Storage = "_billnum", ThisKey = "billnum", IsForeignKey = true)]
        public tblCustbill custbill
        {
            get { return this._billnum.Entity; }
            set { this._billnum.Entity = value; }
        }
   
        [Column(IsPrimaryKey = true, DbType = "INT NOT NULL", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
        public int menuid;
        private EntityRef<tblMENUITEMS> _menuitems;
        [Association(Storage = "_menuitems", ThisKey = "menuid", IsForeignKey = true)]
        public tblMENUITEMS menuitems
        {
            get { return this._menuitems.Entity; }
            set { this._menuitems.Entity = value; }
        }

        int _Qty;
        [Column]
        public int Qty
        {
            get { return _Qty; }
            set { _Qty = value; }
        }
    }
    [Table]
    public class tblEmpJob
    {
        public tblEmpJob() { }
        public tblEmpJob(int EJobID, string EJobDesc, float EJobMinPay, float EJobMaxPay)
        {
            id = EJobID;
            describe = EJobDesc;
            min = EJobMinPay;
            max = EJobMaxPay;
        }

        int _id;
        [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
        public int id
        {
            get { return _id; }
            set { _id = value; }
        }
        string _describe;
        [Column]
        public string describe
        {
            get { return _describe; }
            set { _describe = value; }
        }

        float _min;
        [Column]
        public float min
        {
            get { return _min; }
            set { _min = value; }
        }

        float _max;
        [Column]
        public float max
        {
            get { return _max; }
            set { _max = value; }
        }

    }
    [Table]
    public class tblSeating 
    {
        public tblSeating() { }
        public tblSeating(int TableID, string TableLocation, int TableSize)
        {
            id = TableID;
            location = TableLocation;
            size = TableSize;
        }
        int _id;   
        [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
        public int id
        {
            get { return _id; }
            set { _id = value; }
        }

        string _location;
        [Column]
        public string location
        {
            get { return _location; }
            set { _location = value; }
        }

        int _size;
        [Column]
        public int size
        {
            get { return _size; }
            set { _size = value; }
        }


    }
    
}
